/**
 * Copyright (c) 2010 Jesco Freund.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 3. Neither the name of Backtory nor the names of its contributors may be used
 *    to endorse or promote products derived from this software without
 *    specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *  $Id$
 */


#ifndef __LIBYAR_TYPES_H
#define __LIBYAR_TYPES_H

#include <stdint.h>
#include <unistd.h>

#include <libyar/version.h>


/**
 * Standard data type representing the return value
 * of all external libyar functions being part of the
 * libyar API.
 */
typedef uint64_t yar_result_t;


/**
 * YAR file handle data structure.
 *
 * Before being used, it must be initialized using the YAR_init() macro.
 */
typedef struct
{
	char *fn;				/* file name of YAR container file					*/
	int fd;					/* file descriptor of YAR container file 			*/
	uint64_t version;		/* YAR version										*/
	uint16_t compression;	/* compression algorithm							*/
	uint16_t encryption;	/* encryption algorithm								*/
	uint16_t digest;		/* message digest algorithm							*/
	uint8_t  encrypt_mdt;	/* flag: encrypt meta data table					*/
	uint8_t  compress_mdt;	/* flag: compress meta data table					*/
	uint8_t  encrypt_fmd;	/* flag: encrypt file meta data blocks				*/
	uint8_t  compress_fmd;	/* flag: compress file meta data blocks				*/
	uint8_t  digest_fmd;	/* flag: create digest of file meta data blocks		*/
	uint8_t  encrypt_fcd;	/* flag: encrypt file content data blocks			*/
	uint8_t  compress_fcd;	/* flag: compress file content data blocks			*/
	uint8_t  digest_fcd;	/* flag: create digest of file content data blocks	*/
	uint8_t  encrypt_fi;	/* flag: encrypt file index							*/
	uint8_t  compress_fi;	/* flag: compress file index						*/
	uint64_t dataoffset;	/* offset to beginning of file data blocks			*/
	uint64_t indexoffset;	/* offset to beginning of file index				*/
} yar_handle_t;



typedef struct
{
	uint32_t size;
	uint16_t len;
	unsigned char *name;
} yar_mdt_record_t;


typedef struct
{
	yar_mdt_record_t *listv;
	uint32_t listc;
} yar_mdt_t;


/**
 * YAR file list data structure.
 *
 * Before being used, it must be initialized using the YAR_flist_init() macro.
 */
typedef struct
{
	unsigned char **listv;
	uint32_t listc;
} yar_flist_t;


/**
 * abstract data type representing a thread id
 * supports both, pointer and integer thread ids
 */
typedef struct
{
	void *ptr;
	uint64_t val;
} yar_threadid_t;

#endif /* __LIBYAR_TYPES_H */
